﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace DataModel.Shapes
{
    public abstract class SimpleShape
    {
        /// <summary>
        /// Width (or radius) of the shape
        /// </summary>
        public float Width { get; set; }
        /// <summary>
        /// height (y axis) of the shape
        /// </summary>
        public float Height { get; set; }
        /// <summary>
        /// list of the vertices
        /// </summary>
        public List<Point3D> Vertices { get; set; }
        /// <summary>
        /// depth (z axis) of the shape
        /// </summary>
        public float Depth { get; set; }
        /// <summary>
        /// color of the shape
        /// </summary>
        public Color Color { get; set; }

        public Color ColorBottom
        {
            get
            {
                if (this.Color == null)
                    return Color.White;

                byte r = (byte)(Color.R - 20);
                byte g = (byte)(Color.G - 20);
                byte b = (byte)(Color.B - 20);

                if (r < 0)
                    r=0;

                if (g < 0)
                    g = 0;

                if (b < 0)
                    b = 0;

                return Color.FromArgb(Color.A, r,g, b);
            }
        }
        
        //position
        /// <summary>
        /// x axis position
        /// </summary>
        public float X { get; set; }
        /// <summary>
        /// y axis position
        /// </summary>
        public float Y { get; set; }
        /// <summary>
        /// z axis position
        /// </summary>
        public float Z { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="width">width</param>
        /// <param name="height">height</param>
        /// <param name="depth">depth</param>
        /// <param name="color">color</param>
        /// <param name="x">position x</param>
        /// <param name="y">position y</param>
        /// <param name="z">position z</param>
        public SimpleShape(float width, float height, float depth, Color color, float x, float y, float z)
        {            
            this.Width = width;
            this.Height = height;
            this.Depth = depth;
            this.Color = color;
            this.X = x;
            this.Y = y;
            this.Z = z;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="radius">radius (width = 2*radius)</param>
        /// <param name="color">color</param>
        /// <param name="x">position x</param>
        /// <param name="y">position y</param>
        /// <param name="z">position z</param>
        public SimpleShape(float radius, Color color, float x, float y, float z)
        {
            this.Width = 2 * radius;
            this.Height = 0;
            this.Depth = 0;
            this.Color = color;
            this.X = x;
            this.Y = y;
            this.Z = z;
        }

        /// <summary>
        /// draws shape
        /// </summary>
        public abstract void DrawShape();

        /// <summary>
        /// ckears old and recalculates vertices
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        public abstract void UpdateVertices(float x, float y, float z);
    }
}
